Macromedia Flex Article

Learning Flex Basics (Part 2): Creating a Simple Calculator with Macromedia Flex


Table of Contents

  1. Introduction
  2. Building the Calculator
  3. Create the Application Object
  4. Add a Panel for the Calculator
  5. Add the Calculator Display
  6. Add a Grid to Lay Out the Buttons
  7. Add the Calculator Buttons
  8. Create the CalculatorController Class
  9. Add Properties to the Controller Class
  10. Add Controller Methods
  11. Instantiate the CalculatorController Class
  12. Complete Code Listing for calculator.mxml
  13. Complete Code Listing for CalculatorController.as
  14. Where to Go From Here

Create the Application Object

To begin any Flex application, start with an XML declaration and an Application tag block. The Application tag include a namespace declaration for the MX class library: xmlns:mx="http://www.macromedia.com/2003/mxml". The mx prefix is used with all tags for this library.

  1. Create a new file and save it as calculator.mxml in the flex_tutorials directory.
  2. At the beginning of the file, insert the XML declaration:
    <?xml version="1.0">
    
  3. After the XML declaration, add an Application tag with the MXML namespace:

    <mx:Application xmlns:mx="http://www.macromedia.com/2003/mxml">
    </mx:Application>